package scenic.toolkit.db;

public class DoubleArray extends Array {
	private double[] data;

	public DoubleArray() {
		super(new ArrayType(AtomicType.doubleType, 0));
	}
	
	protected Object getData() {
		return data;
	}
	
	protected void setData(Object data) {
		this.data = (double[])data;
	}
	
	protected Object allocate(int size) {
		return new double[size];
	}
	
	public void write(int position, double[] insertData) {
		super.write(position, insertData, insertData.length);
	}
	
	public void insert(int position, double[] insertData) {
		super.insert(position, insertData, insertData.length);
	}
	
	public void set(int index, double value) {
		if(index >= getLength())
			throw new IndexOutOfBoundsException();
		data[index] = value;
		super.notifyWrite(index, 1);
	}
	
	public double get(int index) {
		if(index >= getLength())
			throw new IndexOutOfBoundsException();
		return data[index];
	}
	
	public void storeTo(StorageOutputStream os) {
		os.write(this);
	}	
}
